package com.xbongbong.saas.domain.entity;

import com.alibaba.fastjson.JSONArray;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * 协同团队基本类
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/2/20 17:21
 * @since v1.0
 */
@Getter
@Setter
public class UserTeamEntity implements Serializable {
    /**
     * id
     */
    private Long id;
    /**
     * 公司id
     */
    private String corpid;
    /**
     * 用户id
     */
    private String userId;
    /**
     * 用户名称
     */
    private String userName;
    /**
     * 头像
     */
    private String userAvatar;
    /**
     * 关联数据id
     */
    private Long dataId;
    /**
     * 是否主负责人
     */
    private Integer isMain;
    /**
     * 删除标志
     */
    private Integer del;
    /**
     * 创建时间
     */
    private Long addTime;
    /**
     * 修改时间
     */
    private Long updateTime;

    /**
     * 表单权限 0：只读  1：可编辑
     */
    private Integer formPermission;
    /**
     * 标签
     */
    private JSONArray labels;

    /**
     * 团队主负责人id，协调人如果没有则为独立协同人，有为负责人同一团队中
     */
    private String teamUserId;

    /**
     * 团队名称，主负责人有，隔离视图下使用
     */
    private String name;

    public UserTeamEntity() {
        long now = DateTimeUtil.getInt();
        this.del=0;
        this.addTime = now;
        this.updateTime = now;
    }

    public UserTeamEntity(String corpid, String userId) {
        this.corpid = corpid;
        this.userId = userId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {return true;}
        if (!(o instanceof UserTeamEntity)) {return false;}

        UserTeamEntity that = (UserTeamEntity) o;

        if (getId() != null ? !getId().equals(that.getId()) : that.getId() != null)  {return false;}
        if (getCorpid() != null ? !getCorpid().equals(that.getCorpid()) : that.getCorpid() != null)  {return false;}
        if (getUserId() != null ? !getUserId().equals(that.getUserId()) : that.getUserId() != null)  {return false;}
        if (getUserName() != null ? !getUserName().equals(that.getUserName()) : that.getUserName() != null)
             {return false;}
        if (getUserAvatar() != null ? !getUserAvatar().equals(that.getUserAvatar()) : that.getUserAvatar() != null)
             {return false;}
        if (getDataId() != null ? !getDataId().equals(that.getDataId()) : that.getDataId() != null)  {return false;}
        if (getIsMain() != null ? !getIsMain().equals(that.getIsMain()) : that.getIsMain() != null)  {return false;}
        if (getDel() != null ? !getDel().equals(that.getDel()) : that.getDel() != null)  {return false;}
        if (getAddTime() != null ? !getAddTime().equals(that.getAddTime()) : that.getAddTime() != null)  {return false;}
        return getUpdateTime() != null ? getUpdateTime().equals(that.getUpdateTime()) : that.getUpdateTime() == null;

    }

    @Override
    public int hashCode() {
        int result = getId() != null ? getId().hashCode() : 0;
        result = 31 * result + (getCorpid() != null ? getCorpid().hashCode() : 0);
        result = 31 * result + (getUserId() != null ? getUserId().hashCode() : 0);
        result = 31 * result + (getUserName() != null ? getUserName().hashCode() : 0);
        result = 31 * result + (getUserAvatar() != null ? getUserAvatar().hashCode() : 0);
        result = 31 * result + (getDataId() != null ? getDataId().hashCode() : 0);
        result = 31 * result + (getIsMain() != null ? getIsMain().hashCode() : 0);
        result = 31 * result + (getDel() != null ? getDel().hashCode() : 0);
        result = 31 * result + (getAddTime() != null ? getAddTime().hashCode() : 0);
        result = 31 * result + (getUpdateTime() != null ? getUpdateTime().hashCode() : 0);
        return result;
    }
}
